import React, { Component } from 'react'

export default class Son extends Component {
    state = {
        username: ''
    }
    render() {
        return (
            <div>
                {/* 方式1 */}
                {/* <p>Son--{this.props.user.name}</p> */}
                {/* 方式2 */}
                {/* <p>Son--{this.state.username}</p> */}
                {/* 方式3 */}
                <p>Son--{this.state.username}</p>
            </div>
        )
    };
    componentDidMount() {
        // console.log(this.props.toChildFn());
        // this.setState({
        //     username: this.props.toChildFn().name
        // })
    }

    getdatafromFather(data) {
        console.log('data', data);
        this.setState({
            username: data.name
        })
    }
}
